import Vue from 'vue'
import VueRouter from 'vue-router'

// 解决导航栏或者底部导航tabBar中的vue-router在3.0版本以上频繁点击菜单报错的问题。
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
    return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const routes = [
/*    {
        path: '/',
        name: 'Manager',
        component: () => import('../views/Manager.vue'),
        redirect: '/home',  // 重定向到主页
        children: [
            { path: 'home', name: 'Home', meta: { name: '系统首页' }, component: () => import('../views/manager/Home') },
            { path: 'user', name: 'User', meta: { name: '用户管理' }, component: () => import('../views/manager/User') },
        ]
    },*/
    {
        path: '/',
        name: 'Manager1',
        component: () => import('../views/Manager1.vue'),
        redirect: '/home',  // 重定向到主页
        children: [
            { path: 'home', name: 'Home', meta: { name: '系统首页' }, component: () => import('../views/manager/Home') },
            { path: 'user', name: 'User', meta: { name: '用户管理' }, component: () => import('../views/manager/User') },
        ]
    },
    {path: '/login', name: 'Login', meta: {name: '登录'}, component: () => import('../views/Login.vue')},
    {path: '/about', name: 'about',component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')}
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router
